package com.gaojinqi.sys.modular.rbac.model;

import com.alibaba.fastjson.annotation.JSONField;
import com.gaojinqi.base.common.model.BaseEntity;
import com.gaojinqi.base.core.jpa.annotation.Equals;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;

import static com.gaojinqi.sys.modular.rbac.model.User.TABLE_NAME;

/**
 * 用户实体
 *
 * @author gaojinqi
 * @version 1.0
 * @since 2020年04月15日
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Entity
@Table(name = TABLE_NAME)
@org.hibernate.annotations.Table(appliesTo = TABLE_NAME, comment = "系统用户表")
public class User extends BaseEntity {

    private static final long serialVersionUID = 4078964904615665444L;

    public static final String TABLE_NAME = "sys_user";

    @Id
    @GeneratedValue(generator = TABLE_NAME + "_uuid")
    @GenericGenerator(name = TABLE_NAME + "_uuid", strategy = "uuid")
    @Column(columnDefinition = "varchar(32)  COMMENT '用户ID'")
    @Equals
    private String userId;

    @Column(columnDefinition = "varchar(64)  COMMENT '用户名'", unique = true)
    private String userName;

    @Column(columnDefinition = "varchar(16)  COMMENT '联系方式'")
    private String phone;

    @Column(columnDefinition = "varchar(32)  COMMENT '密码'")
    @JSONField(serialize = false)
    private String password;

    @Column(columnDefinition = "varchar(32)  COMMENT '盐值'")
    @JSONField(serialize = false)
    private String salt;

    @Column(columnDefinition = "int(4) default 0 COMMENT '启用状态'")
    private Byte state;

    @Column(columnDefinition = "varchar(16)  COMMENT '昵称'")
    private String nickName;

    @Column(columnDefinition = "varchar(16)  COMMENT '真实名称'")
    private String trueName;

    @Column(columnDefinition = "int(2) default 0 COMMENT '性别'")
    private Byte gender;

}
